package com.project.service.impl;

import com.github.pagehelper.PageInfo;
import com.project.bean.OrderBean;
import com.project.bean.ShoppingCarBean;
import com.project.mapper.IOrderInfoMapper;
import com.project.mapper.IOrderMapper;
import com.project.mapper.IShopMapper;
import com.project.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.List;

@Service
@Transactional
public class OrderServiceImpl implements IOrderService {
    @Autowired
    private IOrderMapper orderMapper;
    @Autowired
    private IOrderInfoMapper infoMapper;
    @Autowired
    private IShopMapper shopMapper;
    @Override
    public OrderBean findById(int id) {
        return null;
    }

    @Override
    public PageInfo<OrderBean> findByItemAdmin(int pageNo, String status, LocalDate startDate, LocalDate endDate, Integer userId) {
        return null;
    }

    @Override
    public List<OrderBean> findByItemDeBoy() {
        return null;
    }

    @Override
    public void add(OrderBean orderBean, int userId) {
        //添加订单
        orderMapper.addOrder(orderBean,userId);
        //按用户ID得到购物车集合
        List<ShoppingCarBean> shopList = shopMapper.findByUser(userId);
        //添加订单明细
        infoMapper.addInfo(orderBean.getId(),shopList);
        //清空用户购物车
        shopMapper.delByUser(userId);
    }

    @Override
    public void send(int id) {

    }

    @Override
    public void finish(int id) {

    }
}
